#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>


struct msgbuf
{
	long type;
	char text[1024];
};

int main(int argc, const char *argv[])
{
	key_t key1=ftok("./1.txt",'c');
	int msgid=msgget(key1,IPC_CREAT|0664);
	struct msgbuf mymsg;
	mymsg.type=1;
//	scanf("%s",mymsg.text);
	
	while(1)
	{
		msgrcv(msgid,&mymsg,sizeof(mymsg)-sizeof(long),1,0);
		printf("%s\n",mymsg.text);
	}
	return 0;
}
